import 'package:dio/dio.dart';

class ApiHttpResponse<T> {
  final int errorCode;
  final String errorMessage;
  final T data;

  const ApiHttpResponse({
    required this.errorCode,
    required this.errorMessage,
    required this.data,
  });

  factory ApiHttpResponse.fromResponse(Response response) {
    final resp = response.data as Map<String, dynamic>? ?? {};
    return ApiHttpResponse(
      errorCode: resp['errorCode'],
      errorMessage: resp['errorMessage'],
      data: resp['data'],
    );
  }
}
